package com.lotter.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lotter.service.FianceStatisService;

/**
 * 财务统计
 * 
 * @author panguixiang
 *
 */
@Controller
@RequestMapping("/fiance")
public class FainceController {

	private static Logger logger = Logger.getLogger(FainceController.class);

	@Autowired
	private FianceStatisService fianceStatisService;

	@RequestMapping(value = "page", method = RequestMethod.GET)
	public String fiancepage() {
		return "fiance/fiancelist";
	}
	
	@RequestMapping(value = "present", method = RequestMethod.GET)
	public String present() {
		return "fiance/presentlist";
	}
	/**
	 * 财务列表 
	 * @param startdatestr
	 * @param enddatestr
	 * @param page
	 * @param rows
	 * @return
	 */
	@ResponseBody
	@RequestMapping("fiancelist")
	public Map<String, Object> pageList(@RequestParam(value = "startdatestr", required = false) String startdatestr,
			@RequestParam(value = "enddatestr", required = false) String enddatestr,
			@RequestParam(value = "page", required = false) Integer page,
			@RequestParam(value = "rows", required = false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			fianceStatisService.finacelistPage(startdatestr, enddatestr, page, rows, result);
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * ' 提现 列表
	 * 
	 * @param startdatestr
	 * @param enddatestr
	 * @param page
	 * @param rows
	 * @return
	 */
	@ResponseBody
	@RequestMapping("presentlist")
	public Map<String, Object> presentlist(@RequestParam(value = "startdatestr", required = false) String startdatestr,
			@RequestParam(value = "enddatestr", required = false) String enddatestr,
			@RequestParam(value = "page", required = false) Integer page,
			@RequestParam(value = "rows", required = false) Integer rows) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			fianceStatisService.presentChecklistPage(startdatestr, enddatestr, page, rows, result);
		} catch (Exception e) {
			logger.error(e);
		}
		return result;
	}
	
	/**
	 * 确认提现，修改数据表
	 * @param ids
	 */
	@ResponseBody
	@RequestMapping("dopresent")
	public void dopresent(@RequestParam("ids") String ids) {
		try {
			fianceStatisService.presentDo(ids);
		} catch (Exception e) {
			logger.error(e);
		}
	}
	
}
